// JavaScript Document
// calls php page for variable value, brings in an "=" sign separated string



/*document.addEventListener("deviceready",onDeviceReady,false);
function onDeviceReady() {
	navigator.splashscreen.hide();	
}*/

$.get('http://143.88.103.50:20000/appTrend/AppTrend.aspx', function (data)
{
	// string is separated into an array
	// breaking up data(string)=date~FL1~FL2(strings associated with columns) each string then converted into array
	var splitColumns = data.split("~");
	var i;
	var tempData;
	
	for(i=0; i<pageDataElements.length; i++)
	{
		tempData = splitColumns[i].split("=");
		
		document.getElementById(pageDateElements[i]).innerHTML = tempData[0];
		document.getElementById(pageDataElements[i]).innerHTML = tempData[1];
		
		var identify = pageTrendElements[i].split("_");
		
		if(identify[1] == "unemployment")
		{
			if (tempData[2] > 0) 
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-up  upgR";	//icon-2x
			}
			else if(tempData[2] == 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-minus-sign  upgB";
			}
			else if(tempData[2] < 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-down  upgG";
			}
		}
		else
		{
		
			if (tempData[2] > 0) 
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-up  upgG";	//icon-2x
			}
			else if(tempData[2] == 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-minus-sign  upgB";
			}
			else if(tempData[2] < 0)
			{
				document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-circle-arrow-down  upgR";
			}
		}
	}
	
	
}
)
// checks connection, displays warnings	
.error(function() 
{
	
	for(i=0; i<pageDataElements.length; i++)
	{
		
		document.getElementById(pageDateElements[i]).innerHTML = "Check your internet connection!";
		
		document.getElementById(pageTrendElements[i]).className="icon-fixed-width icon-remove-sign  upgError";
		
	}
		
		
}// End connection check	
);


// 	GLOBAL VARIABLES
// DATA
var pageDataElements = new Array("nation_employment_data", "nation_unemployment_data", "nation_inflation_data", 
								 "nation_gdp_data", "nation_consumerConfidence_data", "nation_caseShillerIndex_data", 
								 "nation_rates_data", "nation_permits_data", "nation_crudeOil_data", 
								 "nation_gas_data", "nation_gold_data", "nation_tenYearTreasury_data",
								 "nation_usDollarIndex_data", "florida_employment_data", "florida_unemployment_data", 
								 "florida_freddieMacHousePriceIndex_data", "florida_consumerConfidenceIndex_data", "florida_unleadedGasolinePrices_data", 
								 "crestview_employment_data", "crestview_unemployment_data", "crestview_flBedTax_data", 
								 "panamaCity_employment_data", "panamaCity_unemployment_data", "panamaCity_flBedTax_data", 
								 "pensacola_employment_data", "pensacola_unemployment_data", "pensacola_flBedTax_data", 
								 "tallahassee_employment_data", "tallahassee_unemployment_data", "daytonaBeach_employment_data", 
								 "daytonaBeach_unemployment_data", "gainesville_employment_data", "gainesville_unemployment_data", 
								 "jacksonville_employment_data", "jacksonville_unemployment_data", "ocala_employment_data", 
								 "ocala_unemployment_data", "palmCoast_employment_data", "palmCoast_unemployment_data", 
								 "orlando_employment_data", "orlando_unemployment_data", "palmBay_employment_data", 
								 "palmBay_unemployment_data", "tampa_employment_data", "tampa_unemployment_data", 
								 "winterHaven_employment_data", "winterHaven_unemployment_data", "veroBeach_employment_data", 
								 "veroBeach_unemployment_data", "fortMyers_employment_data", "fortMyers_unemployment_data", 
								 "miami_employment_data", "miami_unemployment_data", "naples_employment_data", 
								 "naples_unemployment_data", "portStLucie_employment_data", "portStLucie_unemployment_data", 
								 "puntaGorda_employment_data", "puntaGorda_unemployment_data", "sarasota_employment_data", 
								 "sarasota_unemployment_data");
// DATE						
var pageDateElements = new Array("nation_employment_date", "nation_unemployment_date", "nation_inflation_date", 
								 "nation_gdp_date", "nation_consumerConfidence_date", "nation_caseShillerIndex_date", 
								 "nation_rates_date", "nation_permits_date", "nation_crudeOil_date", 
								 "nation_gas_date", "nation_gold_date", "nation_tenYearTreasury_date", 
								 "nation_usDollarIndex_date", "florida_employment_date", "florida_unemployment_date", 
						         "florida_freddieMacHousePriceIndex_date", "florida_consumerConfidenceIndex_date", "florida_unleadedGasolinePrices_date", 
								 "crestview_employment_date", "crestview_unemployment_date", "crestview_flBedTax_date", 
								 "panamaCity_employment_date", "panamaCity_unemployment_date", "panamaCity_flBedTax_date", 
								 "pensacola_employment_date", "pensacola_unemployment_date", "pensacola_flBedTax_date", 
								 "tallahassee_employment_date", "tallahassee_unemployment_date", "daytonaBeach_employment_date", 
								 "daytonaBeach_unemployment_date", "gainesville_employment_date", "gainesville_unemployment_date",
								 "jacksonville_employment_date", "jacksonville_unemployment_date", "ocala_employment_date", 
								 "ocala_unemployment_date", "palmCoast_employment_date", "palmCoast_unemployment_date", 
								 "orlando_employment_date", "orlando_unemployment_date", "palmBay_employment_date", 
								 "palmBay_unemployment_date", "tampa_employment_date", "tampa_unemployment_date", 
								 "winterHaven_employment_date", "winterHaven_unemployment_date", "veroBeach_employment_date", 
								 "veroBeach_unemployment_date", "fortMyers_employment_date", "fortMyers_unemployment_date", 
								 "miami_employment_date", "miami_unemployment_date", "naples_employment_date", 
								 "naples_unemployment_date", "portStLucie_employment_date", "portStLucie_unemployment_date", 
								 "puntaGorda_employment_date", "puntaGorda_unemployment_date", "sarasota_employment_date", 
								 "sarasota_unemployment_date");
// TREND						
var pageTrendElements = new Array("nation_employment_trend", "nation_unemployment_trend", "nation_inflation_trend", 
								  "nation_gdp_trend", "nation_consumerConfidence_trend", "nation_caseShillerIndex_trend", 
								  "nation_rates_trend", "nation_permits_trend", "nation_crudeOil_trend", 
								  "nation_gas_trend", "nation_gold_trend","nation_tenYearTreasury_trend", 
								  "nation_usDollarIndex_trend","florida_employment_trend", "florida_unemployment_trend", 
								  "florida_freddieMacHousePriceIndex_trend", "florida_consumerConfidenceIndex_trend", "florida_unleadedGasolinePrices_trend", 
								  "crestview_employment_trend", "crestview_unemployment_trend", "crestview_flBedTax_trend", 
								  "panamaCity_employment_trend", "panamaCity_unemployment_trend", "panamaCity_flBedTax_trend", 
								  "pensacola_employment_trend", "pensacola_unemployment_trend", "pensacola_flBedTax_trend", 
								  "tallahassee_employment_trend", "tallahassee_unemployment_trend", "daytonaBeach_employment_trend", 
								  "daytonaBeach_unemployment_trend", "gainesville_employment_trend", "gainesville_unemployment_trend", 
								  "jacksonville_employment_trend", "jacksonville_unemployment_trend", "ocala_employment_trend", 
								  "ocala_unemployment_trend", "palmCoast_employment_trend", "palmCoast_unemployment_trend", 
								  "orlando_employment_trend", "orlando_unemployment_trend", "palmBay_employment_trend", 
								  "palmBay_unemployment_trend", "tampa_employment_trend", "tampa_unemployment_trend", 
								  "winterHaven_employment_trend", "winterHaven_unemployment_trend", "veroBeach_employment_trend", 
								  "veroBeach_unemployment_trend", "fortMyers_employment_trend", "fortMyers_unemployment_trend", 
								  "miami_employment_trend", "miami_unemployment_trend", "naples_employment_trend", 
								  "naples_unemployment_trend", "portStLucie_employment_trend", "portStLucie_unemployment_trend", 
								  "puntaGorda_employment_trend", "puntaGorda_unemployment_trend", "sarasota_employment_trend", 
								  "sarasota_unemployment_trend");

//	END GLOBAL VARIABLES